﻿using System.ComponentModel;
using MySqlConnector;

namespace From._1117;

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    } 
    private void menuStrip2_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
    {
        throw new System.NotImplementedException();
    }
    private void Form1_Load(object sender, EventArgs e)
    {
        throw new System.NotImplementedException();
    }

    private void contextMenuStrip1_Opening_1(object sender, CancelEventArgs e)
    {
        throw new System.NotImplementedException();
    }

    private void 文件FToolStripMenuItem_Click(object sender, EventArgs e)
    {
        throw new System.NotImplementedException();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        openFileDialog1=new OpenFileDialog();
        if (openFileDialog1.ShowDialog() == DialogResult.OK)
        {
          //  执行头像上传 
         // 获取文件名
         string fileName = openFileDialog1.FileName;
         File.Copy(fileName,"D:\\1117\\"+Path.GetExtension(fileName));
         this.pictureBox1.Image = Image.FromFile(fileName);
        }
    }
    
    private void button3_Click(object sender, EventArgs e)
    {
        using var connection = new MySqlConnection("server=localhost;port=3306;database=book;user=root;password=123456;charset=utf8mb4;AllowPublicKeyRetrieval=True");
        connection.Open();

        using var command = new MySqlCommand("SELECT field FROM table;", connection);
        using var reader = command.ExecuteReader();
        while (reader.Read())
            Console.WriteLine(reader.GetString(0));
    }
}